home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue28 / opengl / AuxTest / GLAux.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1997-11-09  |  10.6 KB  |  295 lines

  1. unit GLAux;
  2.  
  3. interface
  4.  
  5. uses Windows, OpenGL;
  6.  
  7. const
  8.     // ToolKit Window Types
  9.     Aux_RGB             = 0;
  10.     Aux_RGBA            = Aux_RGB;
  11.     Aux_Index           = 1;
  12.     Aux_Single          = 0;
  13.     Aux_Double          = 2;
  14.     Aux_Direct          = 0;
  15.     Aux_Indirect        = 4;
  16.  
  17.     Aux_Accum           = 8;
  18.     Aux_Alpha           = 16;
  19.     Aux_Depth24         = 32;           // 24-bit depth buffer
  20.     Aux_Stencil         = 64;
  21.     Aux_Aux             = 128;
  22.     Aux_Depth16         = 256;          // 16-bit depth buffer
  23.     Aux_Fixed_332_Pal   = 512;
  24.     Aux_Depth           = Aux_Depth16;  // default is 16-bit depth buffer
  25.  
  26.     // Color Macros
  27.     Aux_Black           = 0;
  28.     Aux_Red             = 13;
  29.     Aux_Green           = 14;
  30.     Aux_Yellow          = 15;
  31.     Aux_Blue            = 16;
  32.     Aux_Magenta         = 17;
  33.     Aux_Cyan            = 18;
  34.     Aux_White           = 19;
  35.  
  36. procedure auxInitDisplayMode (mode: GLenum); stdcall;
  37. procedure auxInitPosition (x, y, width, height: Integer); stdcall;
  38. procedure auxInitWindow (Title: PAnsiChar); stdcall;
  39. procedure auxSwapBuffers; stdcall;
  40. procedure auxReshapeFunc (ReshapeFunc: Pointer); stdcall;
  41. procedure auxIdleFunc (IdleFunc: Pointer); stdcall;
  42. procedure auxMainLoop (MainFunc: Pointer); stdcall;
  43. procedure auxWireSphere (radius: GLDouble); stdcall;
  44. procedure auxSolidSphere (radius: GLDouble); stdcall;
  45. procedure auxWireCube (size: GLDouble); stdcall;
  46. procedure auxSolidCube (size: GLDouble); stdcall;
  47. procedure auxWireBox (width, height, depth: GLDouble); stdcall;
  48. procedure auxSolidBox (width, height, depth: GLDouble); stdcall;
  49. procedure auxWireTorus (innerRadius, outerRadius: GLDouble); stdcall;
  50. procedure auxSolidTorus (innerRadius, outerRadius: GLDouble); stdcall;
  51. procedure auxWireCylinder (radius, height: GLDouble); stdcall;
  52. procedure auxSolidCylinder (radius, height: GLDouble); stdcall;
  53. procedure auxWireCone (base, height: GLDouble); stdcall;
  54. procedure auxSolidCone (base, height: GLDouble); stdcall;
  55. procedure auxWireIcosahedron (radius: GLDouble); stdcall;
  56. procedure auxSolidIcosahedron (radius: GLDouble); stdcall;
  57. procedure auxWireOctahedron (radius: GLDouble); stdcall;
  58. procedure auxSolidOctahedron (radius: GLDouble); stdcall;
  59. procedure auxWireTetrahedron (radius: GLDouble); stdcall;
  60. procedure auxSolidTetrahedron (radius: GLDouble); stdcall;
  61. procedure auxWireDodecahedron (radius: GLDouble); stdcall;
  62. procedure auxSolidDodecahedron (radius: GLDouble); stdcall;
  63. procedure auxWireTeapot (size: GLdouble); stdcall;
  64. procedure auxSolidTeapot (size: GLdouble); stdcall;
  65. procedure auxCloseWindow; stdcall;
  66. procedure auxQuit; stdcall;
  67. procedure auxSetGreyRamp; stdcall;
  68. function  auxGetDisplayModePolicy: GLEnum; stdcall;
  69. function  auxGetDisplayModeID: Integer; stdcall;
  70. function  auxGetDisplayMode: GLEnum; stdcall;
  71. procedure auxCreateFont; stdcall;
  72. function  auxGetColorMapSize: Integer; stdcall;
  73. function  auxGetHWND: hWnd; stdcall;
  74. function  auxGetHDC: hDC; stdcall;
  75. function  auxGetHGLRC: hGLRC; stdcall;
  76.  
  77. implementation
  78.  
  79. const
  80.     auxlib = 'glaux.dll';
  81.  
  82. procedure auxInitDisplayMode;           external auxlib;
  83. procedure auxInitPosition;              external auxlib;
  84. procedure auxSwapBuffers;               external auxlib;
  85. procedure auxReshapeFunc;               external auxlib;
  86. procedure auxIdleFunc;                  external auxlib;
  87. procedure auxMainLoop;                  external auxlib;
  88. procedure auxWireSphere;                external auxlib;
  89. procedure auxSolidSphere;               external auxlib;
  90. procedure auxWireCube;                  external auxlib;
  91. procedure auxSolidCube;                 external auxlib;
  92. procedure auxWireBox;                   external auxlib;
  93. procedure auxSolidBox;                  external auxlib;
  94. procedure auxWireTorus;                 external auxlib;
  95. procedure auxSolidTorus;                external auxlib;
  96. procedure auxWireCylinder;              external auxlib;
  97. procedure auxSolidCylinder;             external auxlib;
  98. procedure auxWireCone;                  external auxlib;
  99. procedure auxSolidCone;                 external auxlib;
  100. procedure auxWireIcosahedron;           external auxlib;
  101. procedure auxSolidIcosahedron;          external auxlib;
  102. procedure auxWireOctahedron;            external auxlib;
  103. procedure auxSolidOctahedron;           external auxlib;
  104. procedure auxWireTetrahedron;           external auxlib;
  105. procedure auxSolidTetrahedron;          external auxlib;
  106. procedure auxWireDodecahedron;          external auxlib;
  107. procedure auxSolidDodecahedron;         external auxlib;
  108. procedure auxWireTeapot;                external auxlib;
  109. procedure auxSolidTeapot;               external auxlib;
  110. procedure auxCloseWindow;               external auxlib;
  111. procedure auxQuit;                      external auxlib;
  112. procedure auxSetGreyRamp;               external auxlib;
  113. function  auxGetColorMapSize;           external auxlib;
  114. function  auxGetDisplayModePolicy;      external auxlib;
  115. function  auxGetDisplayModeID;          external auxlib;
  116. procedure auxCreateFont;                external auxlib;
  117. function  auxGetDisplayMode;            external auxlib;
  118. function  auxGetHWND;                   external auxlib;
  119. function  auxGetHDC;                    external auxlib;
  120. function  auxGetHGLRC;                  external auxlib;
  121. procedure auxInitWindow;                external auxlib name 'auxInitWindowA';
  122.  
  123. end.
  124.  
  125. /*
  126. ** Window Masks
  127. */
  128.  
  129. #define AUX_WIND_IS_RGB(x)      (((x) & AUX_INDEX) == 0)
  130. #define AUX_WIND_IS_INDEX(x)    (((x) & AUX_INDEX) != 0)
  131. #define AUX_WIND_IS_SINGLE(x)   (((x) & AUX_DOUBLE) == 0)
  132. #define AUX_WIND_IS_DOUBLE(x)   (((x) & AUX_DOUBLE) != 0)
  133. #define AUX_WIND_IS_INDIRECT(x) (((x) & AUX_INDIRECT) != 0)
  134. #define AUX_WIND_IS_DIRECT(x)   (((x) & AUX_INDIRECT) == 0)
  135. #define AUX_WIND_HAS_ACCUM(x)   (((x) & AUX_ACCUM) != 0)
  136. #define AUX_WIND_HAS_ALPHA(x)   (((x) & AUX_ALPHA) != 0)
  137. #define AUX_WIND_HAS_DEPTH(x)   (((x) & (AUX_DEPTH24 | AUX_DEPTH16)) != 0)
  138. #define AUX_WIND_HAS_STENCIL(x) (((x) & AUX_STENCIL) != 0)
  139. #define AUX_WIND_USES_FIXED_332_PAL(x)  (((x) & AUX_FIXED_332_PAL) != 0)
  140.  
  141. /*
  142. ** ToolKit Event Structure
  143. */
  144.  
  145. typedef struct _AUX_EVENTREC {
  146.     GLint event;
  147.     GLint data[4];
  148. } AUX_EVENTREC;
  149.  
  150. /*
  151. ** ToolKit Event Types
  152. */
  153. #define AUX_EXPOSE      1
  154. #define AUX_CONFIG      2
  155. #define AUX_DRAW        4
  156. #define AUX_KEYEVENT    8
  157. #define AUX_MOUSEDOWN   16
  158. #define AUX_MOUSEUP     32
  159. #define AUX_MOUSELOC    64
  160.  
  161. /*
  162. ** Toolkit Event Data Indices
  163. */
  164. #define AUX_WINDOWX             0
  165. #define AUX_WINDOWY             1
  166. #define AUX_MOUSEX              0
  167. #define AUX_MOUSEY              1
  168. #define AUX_MOUSESTATUS         3
  169. #define AUX_KEY                 0
  170. #define AUX_KEYSTATUS           1
  171.  
  172. /*
  173. ** ToolKit Event Status Messages
  174. */
  175. #define AUX_LEFTBUTTON          1
  176. #define AUX_RIGHTBUTTON         2
  177. #define AUX_MIDDLEBUTTON        4
  178. #define AUX_SHIFT               1
  179. #define AUX_CONTROL             2
  180.  
  181. /*
  182. ** ToolKit Key Codes
  183. */
  184. #define AUX_RETURN              0x0D
  185. #define AUX_ESCAPE              0x1B
  186. #define AUX_SPACE               0x20
  187. #define AUX_LEFT                0x25
  188. #define AUX_UP                  0x26
  189. #define AUX_RIGHT               0x27
  190. #define AUX_DOWN                0x28
  191. #define AUX_A                   'A'
  192. #define AUX_B                   'B'
  193. #define AUX_C                   'C'
  194. #define AUX_D                   'D'
  195. #define AUX_E                   'E'
  196. #define AUX_F                   'F'
  197. #define AUX_G                   'G'
  198. #define AUX_H                   'H'
  199. #define AUX_I                   'I'
  200. #define AUX_J                   'J'
  201. #define AUX_K                   'K'
  202. #define AUX_L                   'L'
  203. #define AUX_M                   'M'
  204. #define AUX_N                   'N'
  205. #define AUX_O                   'O'
  206. #define AUX_P                   'P'
  207. #define AUX_Q                   'Q'
  208. #define AUX_R                   'R'
  209. #define AUX_S                   'S'
  210. #define AUX_T                   'T'
  211. #define AUX_U                   'U'
  212. #define AUX_V                   'V'
  213. #define AUX_W                   'W'
  214. #define AUX_X                   'X'
  215. #define AUX_Y                   'Y'
  216. #define AUX_Z                   'Z'
  217. #define AUX_a                   'a'
  218. #define AUX_b                   'b'
  219. #define AUX_c                   'c'
  220. #define AUX_d                   'd'
  221. #define AUX_e                   'e'
  222. #define AUX_f                   'f'
  223. #define AUX_g                   'g'
  224. #define AUX_h                   'h'
  225. #define AUX_i                   'i'
  226. #define AUX_j                   'j'
  227. #define AUX_k                   'k'
  228. #define AUX_l                   'l'
  229. #define AUX_m                   'm'
  230. #define AUX_n                   'n'
  231. #define AUX_o                   'o'
  232. #define AUX_p                   'p'
  233. #define AUX_q                   'q'
  234. #define AUX_r                   'r'
  235. #define AUX_s                   's'
  236. #define AUX_t                   't'
  237. #define AUX_u                   'u'
  238. #define AUX_v                   'v'
  239. #define AUX_w                   'w'
  240. #define AUX_x                   'x'
  241. #define AUX_y                   'y'
  242. #define AUX_z                   'z'
  243. #define AUX_0                   '0'
  244. #define AUX_1                   '1'
  245. #define AUX_2                   '2'
  246. #define AUX_3                   '3'
  247. #define AUX_4                   '4'
  248. #define AUX_5                   '5'
  249. #define AUX_6                   '6'
  250. #define AUX_7                   '7'
  251. #define AUX_8                   '8'
  252. #define AUX_9                   '9'
  253.  
  254. /*
  255. ** ToolKit Gets and Sets
  256. */
  257. #define AUX_FD                  1  /* return fd (long) */
  258. #define AUX_COLORMAP            3  /* pass buf of r, g and b (unsigned char) */
  259. #define AUX_GREYSCALEMAP        4
  260. #define AUX_FOGMAP              5  /* pass fog and color bits (long) */
  261. #define AUX_ONECOLOR            6  /* pass index, r, g, and b (long) */
  262.  
  263. extern float auxRGBMap[20][3];
  264.  
  265. #define AUX_SETCOLOR(x, y) (AUX_WIND_IS_RGB((x)) ? \
  266.                            glColor3fv(auxRGBMap[(y)]) : glIndexf((y)))
  267.  
  268. typedef void (CALLBACK* AUXEXPOSEPROC)(int, int);
  269. void APIENTRY auxExposeFunc(AUXEXPOSEPROC);
  270.  
  271. typedef void (CALLBACK* AUXKEYPROC)(void);
  272. void APIENTRY auxKeyFunc(int, AUXKEYPROC);
  273.  
  274. typedef void (CALLBACK* AUXMOUSEPROC)(AUX_EVENTREC *);
  275. void APIENTRY auxMouseFunc(int, int, AUXMOUSEPROC);
  276.  
  277. void APIENTRY auxGetMouseLoc(int *, int *);
  278. void APIENTRY auxSetOneColor(int, float, float, float);
  279. void APIENTRY auxSetFogRamp(int, int);
  280.  
  281. void APIENTRY auxSetRGBMap(int, float *);
  282.  
  283. /* Display Mode Selection Criteria */
  284. enum {
  285.     AUX_USE_ID = 1,
  286.     AUX_EXACT_MATCH,
  287.     AUX_MINIMUM_CRITERIA
  288. };
  289.  
  290. void   APIENTRY auxInitDisplayModePolicy(GLenum);
  291. GLenum APIENTRY auxInitDisplayModeID(GLint);
  292.  
  293.  
  294.  
  295.